

# -----------------------------------------------------------------------------
# Converter funcs
# -----------------------------------------------------------------------------
def toint(x, y=-1):
	if x is None: return y
	if isinstance(x, int): return x
	try: return int(x)
	except: return y

# -----------------------------------------------------------------------------
def tolong(x, y=-1l):
	if x is None: return y
	if isinstance(x, long): return x
	try: return long(x)
	except: return y

# -----------------------------------------------------------------------------
def tofloat(x, y=-1.0):
	if x is None: return y
	if isinstance(x, float): return x
	try: return float(x)
	except: return y

# -----------------------------------------------------------------------------
def tostring(x, y=""):
	if x is None: return y
	if isinstance(x, basestring): return x
	try: return str(x)
	except: return y

